package com.example.union;

import com.example.model.WaterSensor;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.api.common.functions.RichMapFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * Created with IntelliJ IDEA.
 * ClassName: StreamUnion
 * Package: com.example.union
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-07-22
 * Time: 22:42
 */

//联合操作 Union
public class StreamUnion {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        env.setParallelism(1);

        //创建数据流 直接赋值
        DataStreamSource<Integer> source1 = env.fromElements(1, 2, 3, 4);

        DataStreamSource<Integer> source2 = env.fromElements(11, 22, 33, 44);


        //union 最简单的合流操作 数据类型必须相同
        source1.union(source2).print();

        env.execute();

    }
}
